{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<div class="p-3">
    <form class="layui-form gg-form-bar border-x border-t" lay-filter="barsearchform">
        <div class="layui-inline">
            <label class="layui-form-label">姓名</label>
            <div class="layui-input-inline" style="width:240px;">
                <input type="text" name="keywords" placeholder="输入姓名" class="layui-input" autocomplete="off"/>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">专业</label>
            <div class="layui-input-inline" style="width:240px;">
                <select name="cert_major_type" lay-reqText="请选择专业">
                    <option value="">请选择专业类型</option>
                    <option value="1">房建</option>
                    <option value="2">市政</option>
                    <option value="3">机电</option>
                    <option value="4">水利</option>
                    <option value="5">公路</option>
                    <option value="6">矿业</option>
                    <option value="7">通信</option>
                    <option value="8">岩土</option>
                    <option value="9">港口与航道工程</option>
                    <option value="10">暖通空调</option>
                    <option value="11">给水排水</option>
                    <option value="12">动力</option>
                    <option value="13">发输变电</option>
                    <option value="14">供配电</option>
                    <option value="15">建筑</option>
                    <option value="16">造价（土建）</option>
                    <option value="17">造价（安装）</option>
                    <option value="18">水利水电工程</option>
                    <option value="19">注册化工</option>
                    <option value="20">注册环保</option>
                    <option value="21">注册结构</option>
                    <option value="22">道路工程</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">人员类型</label>
            <div class="layui-input-inline" style="width:240px;">
                <select name="p_type" lay-reqText="请选择人员类型">
                    <option value="">请选择人员类型</option>
                    <option value="1">一级注册建筑师</option>
                    <option value="2">二级注册建筑师</option>
                    <option value="3">一级注册结构工程师</option>
                    <option value="4">二级注册结构工程师</option>
                    <option value="5">注册土木工程师(岩土)</option>
                    <option value="6">注册土木工程师(港口与航道工程)</option>
                    <option value="7">注册公用设备工程师(暖通空调)</option>
                    <option value="8">注册公用设备工程师(给水排水)</option>
                    <option value="9">注册公用设备工程师(动力)</option>
                    <option value="10">注册电气工程师(发输变电)</option>
                    <option value="11">注册电气工程师(供配电)</option>
                    <option value="12">注册化工工程师</option>
                    <option value="13">监理工程师</option>
                    <option value="14">一级注册建造师</option>
                    <option value="15">二级注册建造师</option>
                    <option value="16">造价工程师</option>
                    <option value="17">二级造价师</option>
                    <option value="18">三类人员A类</option>
                    <option value="19">三类人员B类</option>
                    <option value="20">三类人员C类</option>
                    <option value="21">施工员</option>
                    <option value="22">质量员</option>
                    <option value="23">安全员</option>
                    <option value="24">标准员</option>
                    <option value="25">材料员</option>
                    <option value="26">机械员</option>
                    <option value="27">劳务员</option>
                    <option value="28">资料员</option>
                    <option value="29">注册土木工程师（水利水电）</option>
                    <option value="30">注册土木工程师（道路工程）</option>
                    <option value="31">注册环保工程师</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">社保情况</label>
            <div class="layui-input-inline" style="width:240px;">
                <select name="security_type" lay-reqText="请选择社保情况">
                    <option value="">请选择社保情况</option>
                    <option value="0">无</option>
                    <option value="1">有</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width: 100px;">证书开始时间</label>
            <div class="layui-input-inline" style="width:240px;">
                <input type="text" name="cert_valid_date" id="cert_valid_date" placeholder="输入证书有效期开始时间"
                       class="layui-input"
                       autocomplete="off"/>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width: 100px;">证书结束时间</label>
            <div class="layui-input-inline" style="width:240px;">
                <input type="text" name="cert_valid_date1" id="cert_valid_date1" placeholder="输入证书有效期结束时间"
                       class="layui-input" autocomplete="off"/>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">有效期状态</label>
            <div class="layui-input-inline" style="width:240px;">
                <select name="cert_valid_from" lay-reqText="证书有效期状态">
                    <option value="">是否即将到期</option>
                    <option value="2">否</option>
                    <option value="1">是</option>
                </select>
            </div>
        </div>
        <div class="layui-input-inline" style="width:150px;">
            <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform"><i
                    class="layui-icon layui-icon-search mr-1"></i>搜索
            </button>
            <button type="reset" class="layui-btn layui-btn-reset" lay-filter="reset">清空</button>
        </div>
    </form>
    <table class="layui-hide" id="test" lay-filter="test"></table>
</div>

<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <span class="layui-btn layui-btn-sm" title="添加人才" lay-event="add">+ 人才录入</span>
    </div>
</script>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
    const moduleInit = ['tool'];
    // {
    //     field: 'check_status', title: '状态', align: 'center', width: 200, templet: function (d) {
    //     var html = '<span class="layui-btn layui-btn-xs layui-bg-' + d.check_status + '">' + d.status_name + '</span>';
    //     return html;
    // }
    // },
    function gouguInit() {
        var form = layui.form, tool = layui.tool, table = layui.table, laydate = layui.laydate, oaTool = layui.oaTool,
            employeepicker = layui.employeepicker;
        laydate.render({
            elem: '#cert_valid_date',
            showBottom: false
        });
        laydate.render({
            elem: '#cert_valid_date1',
            showBottom: false
        });
        layui.pageTable = table.render({
            elem: '#test',
            title: '执照列表',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', {title: '导出EXCEL', layEvent: 'LAYTABLE_EXCEL', icon: 'layui-icon-export'}],
            url: "/bitjob/index/index?index_from={$index_from}", //数据接口
            cellMinWidth: 80,
            page: true, //开启分页
            limit: 20,
            cols: [
                [ //表头
                    {
                        field: 'id',
                        title: '编号',
                        align: 'center',
                        width: 80,
                        templet: function (d) {
                            return d.LAY_INDEX+1
                        }
                    }, {
                    field: 'salesman_name',
                    title: '人员姓名',
                    width: 150,
                }, {
                    field: 'type_name',
                    title: '人员类型',
                    align: 'center',
                    width: 150,
                }, {
                    field: 'cert_major_type',
                    title: '证书类型',
                    align: 'center',
                    width: 150,
                }, {
                    field: 'cert_valid_date',
                    title: '证书有效期',
                    align: 'center',
                    width: 150,
                }, {
                    field: 'cert_valid_type', title: '证书有效期状态', align: 'center', templet: function (d) {
                        if (d.cert_valid_type) {
                            var html = '<span class="layui-btn layui-btn-xs layui-bg" style="background-color: #8a8f97;">' + d.cert_valid_type + '</span>';
                            return html;
                        } else {
                            return '';
                        }
                    }
                }, {
                    field: 'security_type', title: '是否参保', align: 'center', templet: function (d) {
                        if (d.security_type == '0') {
                            return '无';
                        } else {
                            return '有';
                        }
                    }
                }, {
                    field: 'cert_state', title: '证书状态', align: 'center', templet: function (d) {
                        if (d.cert_state == '0') {
                            return '';
                        } else {
                            var html = '<span class="layui-btn layui-btn-xs layui-bg" style="background-color: #8f5536;">锁定中</span>';
                            return html;
                        }
                    }
                },{
                    field: 'money',
                    title: '收证金额',
                    align: 'center',
                    width: 150,
                },{
                    field: 'out_money',
                    title: '出证金额',
                    align: 'center',
                    width: 150,
                },{
                    field: 'cert_money',
                    title: '本期利润',
                    align: 'center',
                    width: 150,
                }, {
                    field: 'right',
                    fixed: 'right',
                    title: '操作',
                    align: 'center',
                    templet: function (d) {
                        var html = '<div class="layui-btn-group">';
                        var btn1 = '';
                         btn1 = '<span class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit">查看</span>';
                        var btn2 = '<span class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</span>';
                        if (d.check_status == 0) {
                            return html + btn1 + btn2 + '</div>';
                        }
                        else {
                            return btn0;
                        }
                    }
                }
                ]
            ]
        });

        //表头工具栏事件
        table.on('toolbar(test)', function (obj) {
            if (obj.event === 'add') {
                tool.side('/bitjob/index/add');
                return;
            }
            if (obj.event === 'LAYTABLE_EXCEL') {
                var formSelect = form.val('barsearchform');
                formSelect.limit = 99999;
                $.ajax({
                    url: '/bitjob/index/index',
                    data: formSelect,
                    success: function (res) {
                        table.exportFile('test', res.data, 'xls');
                    }
                });
                return;
            }
        });
        //监听行工具事件
        table.on('tool(test)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') {
                tool.side('/bitjob/index/add?id=' + data.id);
                return;
            }
            if (obj.event === 'del') {
                layer.confirm('确定要删除吗?', {
                    icon: 3,
                    title: '提示'
                }, function (index) {
                    let callback = function (e) {
                        layer.msg(e.msg);
                        if (e.code == 0) {
                            obj.del();
                        }
                    }
                    tool.delete("/bitjob/index/delete", {id: data.id}, callback);
                    layer.close(index);
                });
            }
        });

        //监听搜索提交
        form.on('submit(webform)', function (data) {
            layui.pageTable.reload({
                where: {
                    keywords: data.field.keywords,
                    cert_major_type: data.field.cert_major_type,
                    p_type: data.field.p_type,
                    cert_valid_date: data.field.cert_valid_date,
                    cert_valid_date1: data.field.cert_valid_date1,
                    security_type: data.field.security_type,
                    cert_valid_from: data.field.cert_valid_from,
                    cate_id: data.field.cate_id,
                    type: data.field.type,
                    check_status: data.field.check_status
                },
                page: {
                    curr: 1
                }
            });
            return false;
        });
    }
</script>
{/block}
<!-- /脚本 -->
